home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / ww_tv.exe / VIEWS.H < prev    next >
C/C++ Source or Header  |  1992-08-13  |  26KB  |  975 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   VIEWS.H                                                               */
  4. /*                                                                         */
  5. /*   Copyright (c) Borland International 1991                              */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the classes TView, TFrame, TScrollBar, TScroller,             */
  9. /*   TListViewer, TGroup, and TWindow                                      */
  10. /*                                                                         */
  11. /* ------------------------------------------------------------------------*/
  12.  
  13. //  Primatech Modification History:
  14. //
  15. //      11-25-91 JLS  Changed change() to have the shift state passed in
  16. //
  17.  
  18.  
  19. #if !defined( __COMMAND_CODES )
  20. #define __COMMAND_CODES
  21.  
  22. const ushort
  23.  
  24. //  Standard command codes
  25.  
  26.     cmValid         = 0,
  27.     cmQuit          = 1,
  28.     cmError         = 2,
  29.     cmMenu          = 3,
  30.     cmClose         = 4,
  31.     cmZoom          = 5,
  32.     cmResize        = 6,
  33.     cmNext          = 7,
  34.     cmPrev          = 8,
  35.     cmHelp          = 9,
  36.  
  37. //  TDialog standard commands
  38.  
  39.     cmOK            = 10,
  40.     cmCancel        = 11,
  41.     cmYes           = 12,
  42.     cmNo            = 13,
  43.     cmDefault       = 14,
  44.  
  45. //  TView State masks 
  46.  
  47.     sfVisible       = 0x001,
  48.     sfCursorVis     = 0x002,
  49.     sfCursorIns     = 0x004,
  50.     sfShadow        = 0x008,
  51.     sfActive        = 0x010,
  52.     sfSelected      = 0x020,
  53.     sfFocused       = 0x040,
  54.     sfDragging      = 0x080,
  55.     sfDisabled      = 0x100,
  56.     sfModal         = 0x200,
  57.     sfDefault       = 0x400,
  58.     sfExposed       = 0x800,
  59.  
  60. // TView Option masks 
  61.  
  62.     ofSelectable    = 0x001,
  63.     ofTopSelect     = 0x002,
  64.     ofFirstClick    = 0x004,
  65.     ofFramed        = 0x008,
  66.     ofPreProcess    = 0x010,
  67.     ofPostProcess   = 0x020,
  68.     ofBuffered      = 0x040,
  69.     ofTileable      = 0x080,
  70.     ofCenterX       = 0x100,
  71.     ofCenterY       = 0x200,
  72.     ofCentered      = 0x300,
  73.  
  74. // TView GrowMode masks 
  75.  
  76.     gfGrowLoX       = 0x01,
  77.     gfGrowLoY       = 0x02,
  78.     gfGrowHiX       = 0x04,
  79.     gfGrowHiY       = 0x08,
  80.     gfGrowAll       = 0x0f,
  81.     gfGrowRel       = 0x10,
  82.  
  83. // TView DragMode masks 
  84.  
  85.     dmDragMove      = 0x01,
  86.     dmDragGrow      = 0x02,
  87.     dmLimitLoX      = 0x10,
  88.     dmLimitLoY      = 0x20,
  89.     dmLimitHiX      = 0x40,
  90.     dmLimitHiY      = 0x80,
  91.     dmLimitAll      = dmLimitLoX | dmLimitLoY | dmLimitHiX | dmLimitHiY,
  92.  
  93. // TView Help context codes
  94.  
  95.     hcNoContext     = 0,
  96.     hcDragging      = 1,
  97.  
  98. // TScrollBar part codes 
  99.  
  100.     sbLeftArrow     = 0,
  101.     sbRightArrow    = 1,
  102.     sbPageLeft      = 2,
  103.     sbPageRight     = 3,
  104.     sbUpArrow       = 4,
  105.     sbDownArrow     = 5,
  106.     sbPageUp        = 6,
  107.     sbPageDown      = 7,
  108.     sbIndicator     = 8,
  109.  
  110. // TScrollBar options for TWindow.StandardScrollBar 
  111.  
  112.     sbHorizontal    = 0x000,
  113.     sbVertical      = 0x001,
  114.     sbHandleKeyboard = 0x002,
  115.  
  116. // TWindow Flags masks
  117.  
  118.     wfMove          = 0x01,
  119.     wfGrow          = 0x02,
  120.     wfClose         = 0x04,
  121.     wfZoom          = 0x08,
  122.  
  123. //  TView inhibit flags
  124.  
  125.     noMenuBar       = 0x0001,
  126.     noDeskTop       = 0x0002,
  127.     noStatusLine    = 0x0004,
  128.     noBackground    = 0x0008,
  129.     noFrame         = 0x0010,
  130.     noViewer        = 0x0020,
  131.     noHistory       = 0x0040,
  132.  
  133. // TWindow number constants
  134.  
  135.     wnNoNumber      = 0,
  136.  
  137. // TWindow palette entries 
  138.  
  139.     wpBlueWindow    = 0,
  140.     wpCyanWindow    = 1,
  141.     wpGrayWindow    = 2,
  142.  
  143. //  Application command codes
  144.  
  145.     cmCut           = 20,
  146.     cmCopy          = 21,
  147.     cmPaste         = 22,
  148.     cmUndo          = 23,
  149.     cmClear         = 24,
  150.     cmTile          = 25,
  151.     cmCascade       = 26,
  152.  
  153. // Standard messages 
  154.  
  155.     cmReceivedFocus     = 50,
  156.     cmReleasedFocus     = 51,
  157.     cmCommandSetChanged = 52,
  158.  
  159. // TScrollBar messages 
  160.  
  161.     cmScrollBarChanged  = 53,
  162.     cmScrollBarClicked  = 54,
  163.  
  164. // TWindow select messages 
  165.  
  166.     cmSelectWindowNum   = 55,
  167.  
  168. //  TListViewer messages
  169.  
  170.     cmListItemSelected  = 56,
  171.  
  172. //  Event masks
  173.  
  174.     positionalEvents    = evMouse,
  175.     focusedEvents       = evKeyboard | evCommand;
  176.  
  177. #endif  // __COMMAND_CODES
  178.  
  179. #if defined( Uses_TCommandSet ) && !defined( __TCommandSet )
  180. #define __TCommandSet
  181.  
  182. class TCommandSet
  183. {
  184.  
  185. public:
  186.  
  187.     TCommandSet();
  188.     TCommandSet( const TCommandSet& );
  189.  
  190.     Boolean has( int cmd );
  191.  
  192.     void disableCmd( int cmd );
  193.     void enableCmd( int cmd );
  194.     void operator += ( int cmd );
  195.     void operator -= ( int cmd );
  196.  
  197.     void disableCmd( const TCommandSet& );
  198.     void enableCmd( const TCommandSet& );
  199.     void operator += ( const TCommandSet& );
  200.     void operator -= ( const TCommandSet& );
  201.  
  202.     Boolean TCommandSet::isEmpty();
  203.  
  204.     TCommandSet& operator &= ( const TCommandSet& );
  205.     TCommandSet& operator |= ( const TCommandSet& );
  206.  
  207.     friend TCommandSet operator & ( const TCommandSet&, const TCommandSet& );
  208.     friend TCommandSet operator | ( const TCommandSet&, const TCommandSet& );
  209.  
  210.     friend int operator == ( const TCommandSet& tc1, const TCommandSet& tc2 );
  211.     friend int operator != ( const TCommandSet& tc1, const TCommandSet& tc2 );
  212.  
  213. private:
  214.  
  215.     int loc( int );
  216.     int mask( int );
  217.  
  218.     static int near masks[8];
  219.  
  220.     uchar cmds[32];
  221.  
  222. };
  223.  
  224. inline void TCommandSet::operator += ( int cmd )
  225. {
  226.     enableCmd( cmd );
  227. }
  228.  
  229. inline void TCommandSet::operator -= ( int cmd )
  230. {
  231.     disableCmd( cmd );
  232. }
  233.  
  234. inline void TCommandSet::operator += ( const TCommandSet& tc )
  235. {
  236.     enableCmd( tc );
  237. }
  238.  
  239. inline void TCommandSet::operator -= ( const TCommandSet& tc )
  240. {
  241.     disableCmd( tc );
  242. }
  243.  
  244. inline int operator != ( const TCommandSet& tc1, const TCommandSet& tc2 )
  245. {
  246.     return !operator == ( tc1, tc2 );
  247. }
  248.  
  249. inline int TCommandSet::loc( int cmd )
  250. {
  251.     return cmd / 8;
  252. }
  253.  
  254. inline int TCommandSet::mask( int cmd )
  255. {
  256.     return masks[ cmd & 0x07 ];
  257. }
  258.  
  259. #endif  // Uses_TCommandSet
  260.  
  261. #if defined( Uses_TPalette ) && !defined( __TPalette )
  262. #define __TPalette
  263.  
  264. class TPalette
  265. {
  266.  
  267. public:
  268.  
  269.     TPalette( const char *, ushort );
  270.     TPalette( const TPalette& );
  271.     ~TPalette();
  272.  
  273.     TPalette& operator = ( const TPalette& );
  274.  
  275.     char& operator[]( int ) const;
  276.  
  277.     char *data;
  278.  
  279. };
  280.  
  281. #endif  // Uses_TPalette
  282.  
  283. #if defined( Uses_TView ) && !defined( __TView )
  284. #define __TView
  285.  
  286. struct write_args
  287. {
  288.     void far *self;
  289.     void far *target;
  290.     void far *buf;
  291.     ushort offset;
  292. };
  293.  
  294. class far TRect;
  295. class far TEvent;
  296. class far TGroup;
  297.  
  298. class TView : public TObject, public TStreamable
  299. {
  300.  
  301. public:
  302.  
  303.     friend void genRefs();
  304.  
  305.     enum phaseType { phFocused, phPreProcess, phPostProcess };
  306.     enum selectMode{ normalSelect, enterSelect, leaveSelect };
  307.  
  308.     TView( const TRect& bounds );
  309.     ~TView();
  310.  
  311.     virtual void sizeLimits( TPoint& min, TPoint& max );
  312.     TRect getBounds();
  313.     TRect getExtent();
  314.     TRect getClipRect();
  315.     Boolean mouseInView( TPoint mouse );
  316.     Boolean containsMouse( TEvent& event );
  317.  
  318.     void locate( TRect& bounds );
  319.     virtual void dragView( TEvent& event, uchar mode,   //  temporary fix
  320.       TRect& limits, TPoint minSize, TPoint maxSize ); //  for Miller's stuff
  321.     virtual void calcBounds( TRect& bounds, TPoint delta );
  322.     virtual void changeBounds( const TRect& bounds );
  323.     void growTo( short x, short y );
  324.     void moveTo( short x, short y );
  325.     void setBounds( const TRect& bounds );
  326.  
  327.     virtual ushort getHelpCtx();
  328.  
  329.     virtual Boolean valid( ushort command );
  330.  
  331.     void hide();
  332.     void show();
  333.     virtual void draw();
  334.     void drawView();
  335.     Boolean exposed();
  336.     void hideCursor();
  337.     void drawHide( TView *lastView );
  338.     void drawShow( TView *lastView );
  339.     void drawUnderRect( TRect& r, TView *lastView );
  340.     void drawUnderView( Boolean doShadow